package day8.homeworkII;

public class Task7 {
    public static void main(String[] args) {
        int[] list = {1,2,3,4};

        int[] list2 = SelectionSort(list);

    }

    public static int[] SelectionSort(int[] arr){
        for (int i = 0; i < arr.length - 1; i++){
            int minIndex = i;
            for (int j = i + 1; j < arr.length; j++){
                if (arr[j] < arr[minIndex]) minIndex = j;
            }

            if (minIndex != i){
                int tmp = arr[i];
                arr[i] = arr[minIndex];
                arr[minIndex] = tmp;
            }
        }

        return arr;
    }
}
